import dt from '@dt/dt'
import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'

class SearchOpt extends Opt {

  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        key: 'msgTitle',
        title: '消息标题',
        labelWidth: 94,
        placeholder: '请输入消息标题',
        input: {},
        xl: 4
      },
      this.organization(),
      {
        key: 'saveState',
        title: '发送状态',
        select: {
          multiple: true,
          key: 'saveState',
          options: dt.dictInfo().msgType
        },
        xl: 4
      },
      {
        key: 'date',
        title: '创建日期',
        date: {
          type: 'daterange',
        },
        data: {
          to: (val) => {
            return {
              createTimeStart: val[0],
              createTimeEnd: val[1]
            }
          }
        },
        xl: 4
      },
    ]
  }

  organization() {
    let orgs = []
    let opt = {
      key: 'sendCompany',
      title: '接收公司',
      tree: {
        options: orgs,
      },
      xl: 6
    }
    toolMgr.organization(2).then(res => {
      orgs = res
      opt.tree.options = orgs
    })
    return opt
  }
}

export default SearchOpt